import qs from 'qs'
import request, { RequestReturnType } from '/@/utils/request'
interface User {
  phone: number | null
  password: string | number | null
}

export const loginApi = (form: User): RequestReturnType => {
  return request({
    method: 'POST',
    url: '/front/user/login',
    data: qs.stringify(form)
  })
}

export const getUserApi = (): RequestReturnType => {
  return request({
    method: 'GET',
    url: '/front/user/getInfo'
  })
}

export const getUserPages = (data: any): RequestReturnType => {
  return request({
    method: 'POST',
    url: '/boss/user/getUserPages',
    data: data
  })
}

export const getRoleByUserId = (id: string | number):RequestReturnType => {
  return request({
    method: 'GET',
    url: `/boss/role/user/${id}`
  })
}

// 启用用户
export const enableUser = (userId: number): RequestReturnType => {
  return request({
    method: 'get',
    url: '/boss/user/enableUser',
    params: { userId }
  })
}
// 封禁用户
export const forbidUser = (userId: number): RequestReturnType => {
  return request({
    method: 'POST',
    url: '/boss/user/forbidUser',
    data: { userId }
  })
}
